<?php
namespace app\index\validate;

use think\Validate;

class Reg extends Common
{
    protected $rule = [
        'vercode' => 'require|checkCode',
        'agreement'=>'require',
        'password' => 'require|length:6,10',
        'repassword' => 'require|confirm:password',
        'phone'=> 'require|regex:1\d{10}|unique:user',
        'nickname'  =>  'require|alphaNum|length:6,8|unique:user',
        'email'=>'require|email|unique:user'
    ];

     protected $message  =   [
        'agreement.require' => '服务条款必须同意',
        'vercode.require' => '人类验证错误',
        'password.require' => '密码不能为空',
        'password.length' => '密码必须长度必须是6-10',
        'repassword.confirm' => '两次密码不一致',
    ];

    protected $scene = [
        'reg'=>['vercode','agreement','password','repassword','phone','nickname'],
        'save'  =>  ['phone','nickname','email'],
    ];

    // public function checkCode($value,$rule,$data)
    // {
    //     if($value==session('answer')){
    //         return true;
    //     }else{
    //         return "人类验证不通过";
    //     }
    // }

}
